﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace VFCons
{
	public partial class SnapExposureLights : UserControl
	{
		public SnapExposureLights()
		{
			InitializeComponent();
		}

		public bool EnableSnap
		{
			get =>checkBoxEnabled.Checked;
			set => checkBoxEnabled.Checked = value;
		}
		public int Exposure
		{
			get
			{
				try
				{
					int ex = Convert.ToInt32(textBoxExposure.Text);
					if(ex<0)
					{
						MessageBox.Show(this, "曝光值输入错误" + Environment.NewLine, "ERROR");
						throw new ArgumentNullException("Exposure");
					}
					else
						return ex;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "曝光值输入错误" + Environment.NewLine + ex.Message, "ERROR");
					throw ex;
				}
			}
			set
			{
				if (value < 0) { MessageBox.Show(this, "曝光值输入错误" + Environment.NewLine, "ERROR"); return; }
				textBoxExposure.Text = value.ToString();
			}
		}

		public int LightBack
		{
			get
			{
				try
				{
					int ex = Convert.ToUInt16(textBoxLightBack.Text);
					if (ex < 0 || ex > 100)
					{
						MessageBox.Show(this, "背光源亮度输入错误" + Environment.NewLine, "ERROR");
						throw new ArgumentNullException("Exposure");
					}
					else
						return ex;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "背光源亮度输入错误" + Environment.NewLine + ex.Message, "ERROR");
					throw ex;
				}
			}
			set
			{
				if (value < 0 || value > 100) { MessageBox.Show(this, "背光源亮度输入错误" + Environment.NewLine, "ERROR"); return; }
				textBoxLightBack.Text = value.ToString();
			}
		}

		public int LightFore
		{
			get
			{
				try
				{
					int ex = Convert.ToUInt16(textBoxLightUp.Text);
					if (ex < 0 || ex > 100)
					{
						MessageBox.Show(this, "上光源亮度输入错误" + Environment.NewLine, "ERROR");
						throw new ArgumentNullException("Exposure");
					}
					else
						return ex;
				}
				catch (Exception ex)
				{
					MessageBox.Show(this, "上光源亮度输入错误" + Environment.NewLine + ex.Message, "ERROR");
					throw ex;
				}
			}
			set
			{
				if (value < 0 || value > 100) { MessageBox.Show(this, "上光源亮度输入错误" + Environment.NewLine, "ERROR"); return; }
				textBoxLightUp.Text = value.ToString();
			}
		}
	}
}
